import { EPokerStatus, Esuit } from "../ConfigEnum";

export  class Poker
{
    public point_:number=-1;
    public suit_:Esuit=Esuit.HEITAO;
    public  status:EPokerStatus=EPokerStatus.CLOSE;
  
     //构造函数  +?是可以为空
     constructor(point?:number,suit?:Esuit,status?:EPokerStatus)
     {
         this.point_=point;
         this.suit_=suit;
         this.status=status;
     }

}
class  PokerGroup
{
    public get pokers():Poker[]{ return this._pokers }

    public _pokers :Poker []=[]
}
/**
 * 牌局的数据
 */
export class GameDB{
    /*************************************************
      * public static API
     ************************************************/
   
    public static Create():GameDB
    {
        let gameDB=new GameDB()
        return gameDB
    }
    public static readonly CONST_RECEIVE_GROUPS:number=4;   //只读属性 被 readonly 标记的属性只能在声明时或类的构造函数中赋值
    public static readonly CONST_PLAY_GROUPS:number=7;
    /*************************************************
      * public  API
     ************************************************/

    /*************************************************
    * private API
     ************************************************/
    constructor(){
         //初始化牌局结构
         for(let i=0;i<GameDB.CONST_RECEIVE_GROUPS;++i)
         {
             let pokerGroup=new PokerGroup();
             this._receiveAreaPokers.push(pokerGroup);
         }
         for(let i=0;i<GameDB.CONST_PLAY_GROUPS;++i)
         {
             let pokerGroup=new PokerGroup();
             this._playAreaPokerGroups.push(pokerGroup);
         }
          //初始化扑克数据
          for (let point = 1; point <=13; point++) {
            for (let suit = 0; suit < 4; suit++) {
               let poker_=new Poker(point,suit,EPokerStatus.CLOSE);
               this._pokers.push(poker_);
            }            
         }
    }
     /*************************************************
      * getter &setter
     ************************************************/
     public get pokers():Poker[]{return this._pokers }
     public get CloseAreaPokers():Poker[]{return this._CloseAreaPokers }
     public get openAreaPokers():Poker[]{return this._openAreaPokers }
     public get receiveAreaPokers():PokerGroup[]{return this._receiveAreaPokers }
     public get playAreaPokerGroups():PokerGroup[]{return this._playAreaPokerGroups }
      /*************************************************
      *property
     ************************************************/
      //所以扑克的原始数据
      private _pokers:Poker[]=[]
      //发牌区盖着的扑克
      private _CloseAreaPokers:Poker[]=[]
      //发牌区掀开的扑克
      private _openAreaPokers:Poker[]=[]
      //收牌区组
      private _receiveAreaPokers:PokerGroup[]=[]
      //玩牌区组
      private _playAreaPokerGroups:PokerGroup[]=[]
}
